/**
* Author - Sofia Arndt
* created - 11.11.08
* actualisiert - 12.11.08
*/
package de.fhhannover.inform.wari.grp8.gui;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import java.io.*;

import javax.swing.JPanel;

@SuppressWarnings("serial")
public class HelpMenu extends JFrame implements ActionListener
{
	private JPanel mPanel; 
	private JTextArea mArea;
	private JScrollPane mPane;	
	private JButton mButton;
	private Gui_Controller mGuiController;
	private Color mColor;
	
	public HelpMenu(Gui_Controller gc){
		mGuiController = gc;
		setSize(480, 480);
		setLocation(420, 150);	
		setTitle("Spielregeln");
		setResizable(false);		//Fensterparameter koennen nicht geaendert werden 
		initComponents();
		settingComponents();
				
		try {
			getTxtDateiOutJar("/regeln/regeln.txt");         
        } catch (Exception e) {
            e.printStackTrace();
        }
	}
	private void initComponents() {

		mPanel = new JPanel();
//		mPanel.setLayout(null);
		mColor = mGuiController.getColor();
		mArea = new JTextArea();
//		mArea.setWrapStyleWord(true); 

	    mPane = new JScrollPane(mArea);
	    mArea.setFont(new Font("Serif", Font.ITALIC, 16));
	    mArea.setWrapStyleWord(true);
	    mButton = new JButton("Schliessen");
	    mPane.setPreferredSize(new Dimension(450, 390));
	    
//	    getContentPane().add(mPane, "Center");
	}
		
	private void settingComponents(){
	    mArea.setEditable(false);
	    mPanel.add(mPane);
		mPanel.add(mButton);
		mButton.setBounds(115, 300, 100, mButton.getPreferredSize().height);
		mButton.addActionListener(this);
	    mPanel.setBackground(mColor);
		getContentPane().add(mPanel);
//		setVisible(true);
//		setDefaultCloseOperation(EXIT_ON_CLOSE);
	}
	
	public void getTxtDateiOutJar(String path) {
	      try {
	         InputStream inStream = this.getClass().getResourceAsStream(path);
	         BufferedReader in = new BufferedReader(new InputStreamReader(inStream));
//	         String line = null;
	         int line ;
	         while ((line = in.read()) != -1) {
	            mArea.append(""+(char)line);
	         }
	      } catch (Exception e) {
	         e.printStackTrace();
	      }
	   } 
	public void actionPerformed(ActionEvent e) {
		Object source = e.getSource();
		if(source == mButton){
			setVisible(false);  }
		  
		}
}